package com.module.product.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import base.dao.GenericHibernateDao;

import com.module.product.vo.AttrItemCombox;

/**
 * 属性对应的下拉类型的属性值Dao管理类
 * @author dengsq
 * @time 2012-1-5
 * @version 1.0
 *
 */
public class AttrItemComboxDao extends GenericHibernateDao<AttrItemCombox,String>{

	private AttrItemComboxDao(){}
	
	private static AttrItemComboxDao dao;
	
	public synchronized static AttrItemComboxDao getInstance(){
		if(dao == null)
			dao = new AttrItemComboxDao();
		return dao;
	}
	
	/**
	 * 根据属性id删除
	 * @param session 
	 * @param attrId 属性id
	 * @throws Exception
	 */
	public void delComboxByAttrId(Session session,String attrId) throws Exception{
		String delHql = "delete  from AttrItemCombox where attrId = ? ";
		Query query = session.createQuery(delHql);
		query.setParameter(0, attrId);
		query.executeUpdate();
	}
	
	/**
	 * 根据属性id查询下拉属性值
	 * @param session
	 * @param attrId
	 * @return List<String>  拉属性值集
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<String> getComboxByAtrrId(Session session,String attrId)throws Exception{
		String selHql = "select  displayvalue  from AttrItemCombox where attrId = ? ";
		Query query = session.createQuery(selHql);
		query.setParameter(0, attrId);
		return query.list();
	}
	
}
